<template>
    <div class="content">
        <!--<template v-if="loading" style="text-align:center;">
            <van-row>
                <van-col span="24" style="margin-top:120px; text-align:center;">
                    <van-loading type="spinner" size="48px" text-size="24px" vertical>
                        {[loadingText}}
                    </van-loading>
                </van-col>
            </van-row>
        </template>-->
        <!--人员基本信息-->
        <div>
            <div class="title">人员基本信息</div>
            <van-field
                    v-model="formItem.name"
                    label="姓名："
                    type="text"
                    placeholder="一经提交无法修改"
                    @focus="bodyScrollTop"
                    class="suggest"
            />
            <div class="suggest van-cell van-field">
                <div class="van-cell__title van-field__label">
                    <span>性别：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <van-radio-group v-model="formItem.sex">
                            <van-radio name="男" value="男" icon-size="18px">男</van-radio>
                            <van-radio name="女" value="女" icon-size="18px">女</van-radio>
                        </van-radio-group>
                    </div>
                </div>
            </div>
            <!--<van-cell @click="cardTypeBtn" title="证件类型：" value="请选择证件类型" arrow-direction="down" is-link />-->
            <div class="suggest van-cell van-field">
                <span>证件类型：</span>
                <van-dropdown-menu>
                    <van-dropdown-item v-model="formItem.card_type" :options="cardTypeOption"/>
                </van-dropdown-menu>
            </div>
            <van-field
                    v-if="formItem.card_type !== 5"
                    v-model="formItem.card_no"
                    label="证件号码："
                    type="text"
                    @focus="bodyScrollTop"
                    @blur="identityCardno"
                    placeholder="请输入证件号码"
            />
            <van-field
                    v-if="formItem.card_type === 5"
                    v-model="formItem.card_no"
                    label="证件号码："
                    type="text"
                    @focus="bodyScrollTop"
                    @blur="identityCardno"
                    placeholder="无身份证填写父母身份证号"
            />
            <van-field
                    v-model="formItem.tel"
                    type="tel"
                    label="手机号码："
                    @focus="bodyScrollTop"
                    placeholder="请输入手机号"
            />
            <van-field
                    v-model="formItem.sms"
                    center
                    clearable
                    label="短信验证码"
                    placeholder="请输入短信验证码"
            >
                <van-button slot="button" size="small" type="primary" @click="showMobileCodeAction">发送验证码</van-button>
            </van-field>
            <div class="suggest van-cell van-field">
                <div class="van-cell__title van-field__label radio-item">
                    <span>是否常住居民：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <van-radio-group v-model="formItem.is_permanent">
                            <van-radio name="1" value="1" icon-size="18px">是</van-radio>
                            <van-radio name="0" value="0" icon-size="18px">否</van-radio>
                        </van-radio-group>
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field">
                <span>区域类型：</span>
                <van-dropdown-menu>
                    <van-dropdown-item v-model="formItem.area_type" :options="areaTypeOption" @change="areaTypeChange"/>
                </van-dropdown-menu>
            </div>
            <div class="suggest van-cell van-field">
                <span>现居区域：</span>
                <van-dropdown-menu>
                    <van-dropdown-item v-model="formItem.area_id" :options="areaList" @change="areaChange"/>
                </van-dropdown-menu>
            </div>
            <div class="suggest van-cell van-field">
                <span>现居街道：</span>
                <van-dropdown-menu>
                    <van-dropdown-item v-model="formItem.street_id" :options="streetList" @change="streetChange"/>
                </van-dropdown-menu>
            </div>
            <div class="suggest van-cell van-field" v-if="formItem.area_type === 1">
                <span>现居社区：</span>
                <van-dropdown-menu>
                    <van-dropdown-item v-model="formItem.community_id" :options="communityList"/>
                </van-dropdown-menu>
            </div>
            <van-field
                    v-if="formItem.area_type === 2"
                    v-model="formItem.community"
                    type="text"
                    label="现居乡村："
                    placeholder="请输入现居乡村"
            />
            <div class="suggest van-cell van-field">
                <div class="van-cell__title van-field__label">
                    <span>居住地址：</span>
                </div>
                <div class="van-cell__value" @click="chooseMap('main')">
                    <div class="address-box">{{formItem.loc_title}}</div>
                    <div class="address-box">{{formItem.loc_address}}</div>
                </div>
            </div>
            <!--<van-field
                    v-model="formItem.loc_address"
                    autosize
                    readonly
                    type="textarea"
                    label="居住地址："
                    @focus="bodyScrollTop"
                    @click="chooseMap('main')"
                    placeholder="请选择居住地址"
            >
            </van-field>-->
            <van-field
                    v-model="formItem.house_num"
                    type="text"
                    label="门牌号："
                    @focus="bodyScrollTop"
                    placeholder="请输入门牌号"
            >
            </van-field>
            <epidemic-other-handle ref="otherHandle" :tabIndex="routeObj.tabCurrentIndex"
                                   :formData="formItem"></epidemic-other-handle>
        </div>
        <!--来(返)沈情况-->
        <div class="tou">
            <div class="title">来(返)沈情况</div>
            <div class="div1">
                <div class="van-cell van-field">
                    <div class="van-cell__title van-field__label radio-item">
                        <span>来(返)沈出发地：</span>
                    </div>
                    <div class="van-cell__value" @click="chufaBtn">
                        <div class="van-field__body">
                            {{formItem.departure}}
                        </div>
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field" v-if="cardnoState">
                <span>来(返)沈事由：</span>
                <van-dropdown-menu>
                    <van-dropdown-item v-model="formItem.back_reason" :options="backReasonOption"/>
                </van-dropdown-menu>
            </div>
            <div class="div1" v-if="formItem.is_permanent === '0'">
                <div class="van-cell van-field">
                    <div class="van-cell__title van-field__label radio-item">
                        <span>来(返)沈时间：</span>
                    </div>
                    <div class="van-cell__value" @click="arriveTimeBtn">
                        <div class="van-field__body">
                            {{formItem.arrive_time}}
                        </div>
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field">
                <div class="van-cell__title van-field__label radio-item">
                    <span>是否途经武汉市：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <van-radio-group v-model="formItem.wuhan_radio">
                            <van-radio name="1" value="1" icon-size="18px">是</van-radio>
                            <van-radio name="0" value="0" icon-size="18px">否</van-radio>
                        </van-radio-group>
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field">
                <div class="van-cell__title van-field__label radio-item">
                    <span>是否途经温州市：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <van-radio-group v-model="formItem.wenzhou_radio">
                            <van-radio name="1" value="1" icon-size="18px">是</van-radio>
                            <van-radio name="0" value="0" icon-size="18px">否</van-radio>
                        </van-radio-group>
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field">
                <div class="van-cell__title van-field__label radio-item">
                    <span>是否途经湖北其它城市：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <van-radio-group v-model="formItem.hubei_radio">
                            <van-radio name="1" value="1" icon-size="18px">是</van-radio>
                            <van-radio name="0" value="0" icon-size="18px">否</van-radio>
                        </van-radio-group>
                    </div>
                </div>
            </div>
        </div>
        <!--其它信息-->
        <div class="other-info">
            <div class="title">其它信息</div>
            <div class="suggest van-cell van-field">
                <div class="van-cell__title van-field__label radio-item">
                    <span>是否集中住宿务工人员：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <van-radio-group v-model="formItem.wugong_radio">
                            <van-radio name="1" value="1" icon-size="18px">是</van-radio>
                            <van-radio name="0" value="0" icon-size="18px">否</van-radio>
                        </van-radio-group>
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field" v-if="formItem.wugong_radio == 1">
                <div class="van-cell__title van-field__label">
                    <span>企业名称：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <input v-model="formItem.wugong_name" type="text"
                               placeholder="请输入企业名称"
                               @focus="bodyScrollTop"
                               class="van-field__control">
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field">
                <div class="van-cell__title van-field__label radio-item">
                    <span>是否集中住宿在校学生：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <van-radio-group v-model="formItem.zaixiao_radio">
                            <van-radio name="1" value="1" icon-size="18px">是</van-radio>
                            <van-radio name="0" value="0" icon-size="18px">否</van-radio>
                        </van-radio-group>
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field" v-if="formItem.zaixiao_radio == 1">
                <div class="van-cell__title van-field__label">
                    <span>学校名称：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <input v-model="formItem.zaixiao_name"
                               type="text"
                               placeholder="请输入学校名称"
                               @focus="bodyScrollTop"
                               class="van-field__control">
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field">
                <div class="van-cell__title van-field__label radio-item">
                    <span>是否宾馆酒店住宿客人：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <van-radio-group v-model="formItem.jiudian_radio">
                            <van-radio name="1" value="1" icon-size="18px">是</van-radio>
                            <van-radio name="0" value="0" icon-size="18px">否</van-radio>
                        </van-radio-group>
                    </div>
                </div>
            </div>
            <div class="suggest van-cell van-field" v-if="formItem.jiudian_radio == 1">
                <div class="van-cell__title van-field__label">
                    <span>宾馆酒店名称：</span>
                </div>
                <div class="van-cell__value">
                    <div class="van-field__body">
                        <input v-model="formItem.jiudian_name"
                               type="text"
                               placeholder="请输入宾馆酒店名称"
                               @focus="bodyScrollTop"
                               class="van-field__control">
                    </div>
                </div>
            </div>
        </div>
        <div class="div-bot">
            <div class="city-card-common-btn" @click="submit">提交</div>
        </div>
        <!--选择证件类型 上拉菜单/弹出层-->
        <!--<van-action-sheet
                :show="cardTypeShow"
                :actions="cardTypeOption"
                description="请选择证件类型"
        />
        <van-popup v-model="cardTypeShow" position="bottom">
            <template v-for="(item, index) in cardTypeOption">
                <van-cell :key="index" @click="cardTypeChooseBtn" :title="item.text" :value="item.value" />
            </template>
        </van-popup>-->
        <!--选择区域弹出层-->
        <van-popup v-model="provinceShow" position="bottom">
            <van-area :area-list="provinceList"
                      value="210100"
                      @confirm="provinceSubmit"
                      @cancel="provinceCancel"
            />
        </van-popup>
        <!--选择日期弹出层-->
        <van-popup v-model="dateShow" position="bottom">
            <van-datetime-picker
                    v-model="datePicker"
                    type="date"
                    :max-date="currentDate"
                    @confirm="dateSubmit"
                    @cancel="dateCancel"
            />
        </van-popup>
        <!--        弹出手机号图片验证码-->
        <van-popup v-model="mobileVerifyModel" position="bottom">
            <van-form validate-first @submit="onSendMobile" @failed="onFailed">
                <div class="mobile-verify-code">
                    <img :src="mobileQrimg"/>
                </div>
                <van-field v-model="mobileVerifyCode" name="code" label="验证码"/>
                <div style="margin: 16px;">
                    <van-button round block type="info" native-type="submit">
                        确定
                    </van-button>
                </div>
            </van-form>
        </van-popup>
    </div>
</template>

<script>
// 接口（新）
import { insertPermit, getUserPermitByOpenId } from '@/api/yi-qing-fang-kong.js'
// 获取用户信息new
import { getUserLoginInfo, getCodePic, createVerificationCode } from '@/api/wx-api'
// vant组件
import {
  // Dialog,
  Toast
} from 'vant'
// 页面模拟数据
import mockData from './data/mockData.js'
// 工具
import { identityCodeValid, identityCardnoSY, identityMobile } from '@/libs/tools'
// 组件
import EpidemicOtherHandle from '../epidemic-other-handle/new'
import wx from 'weixin-js-sdk'

export default {
  components: { EpidemicOtherHandle },
  data () {
    return {
      formItem: {
        // tab组件中数据
        address: [{ loc_province: '', loc_city: '', loc_title: '', loc_address: '' }],
        person: [{
          relation: '',
          name: '',
          cardno: '',
          loc_province: '',
          loc_city: '',
          loc_title: '',
          loc_address: ''
        }],
        children: [{ relation: '', name: '', cardno: '' }],
        // 表单数据
        name: '',
        sex: '',
        sms: '',
        card_type: 0,
        card_no: '',
        tel: '',
        is_permanent: '', // 是否常住
        area_type: '', // 区域类型
        area_id: '',
        street_id: '',
        community_id: '',
        area: '',
        street: '',
        community: '',
        loc_province: '', // 地图选取后的省
        loc_city: '', // 地图选取后的市
        loc_title: '', // 地图选取后的地址名
        loc_address: '', // 地图选取后的具体地址
        house_num: '', // 门牌号
        arrive_time: '', // 来（返）沈时间
        back_reason: '', // 来（返）沈事由
        departure: '',
        originate_province: '', // 出发地-省
        originate_city: '', // 出发地-市
        concentration_type: '', // 其它信息类型
        concentration_type_remark: '', // 其它信息地点名称
        viaway: '', // 途径地
        wuhan_radio: '',
        wenzhou_radio: '',
        hubei_radio: '',
        wugong_radio: '',
        zaixiao_radio: '',
        jiudian_radio: '',
        serverId: ''
      },
      loading: false,
      loadingText: '加载中',
      routeObj: {}, // 路由对象
      provinceList: mockData,
      cardTypeOption: mockData.cardTypeOption,
      areaTypeOption: mockData.areaTypeOption,
      backReasonOption: mockData.backReasonOption,
      areaList: [],
      streetList: [],
      communityList: [],
      cardTypeShow: false,
      provinceShow: false,
      dateShow: false,
      datePicker: new Date(),
      currentDate: new Date(),
      cardnoState: false, // 身份证检验状态
      mobileVerifyModel: false,
      mobileQrimg: '',
      mobileVerifyKey: '', // 图片验证码key
      mobileVerifyCode: '' // 图片验证码
    }
  },
  methods: {
    chooseMap (type) {
      this.$router.push({
        name: 'epidemic-map',
        query: {
          type: type,
          formData: this.formItem
        }
      })
    },
    // 身份证校验
    identityCardno () {
      this.cardnoState = identityCardnoSY(this.formItem.card_no)
      console.log('身份检验', this.cardnoState)
    },
    menuDataHandle () {
      let newAreaList = []
      mockData.areaList.forEach(item => {
        newAreaList.push({
          text: item.name,
          value: item.id,
          id: item.id
        })
      })
      this.areaList = newAreaList
      // 数据回显处理
      if (this.formItem.street_id !== '') {
        this.areaChange()
        if (this.formItem.community_id !== '') {
          this.streetChange()
        }
      }
    },
    areaTypeChange () {
      if (this.formItem.area_type === 2) {
        this.formItem.community = ''
      }
    },
    areaChange () {
      let newStreetList = []
      mockData.streetList.forEach(item => {
        if (this.formItem.area_id === item.pid) {
          let obj = {}
          obj.text = item.name
          obj.value = item.id
          obj.id = item.id
          newStreetList.push(obj)
        }
      })
      this.streetList = newStreetList
      console.log('当前街道列表', this.streetList)
    },
    streetChange () {
      let newCommunityList = []
      mockData.communityList.forEach(item => {
        if (this.formItem.street_id === item.pid) {
          let obj = {}
          obj.text = item.name
          obj.value = item.id
          obj.id = item.id
          newCommunityList.push(obj)
        }
      })
      this.communityList = newCommunityList
      console.log('当前社区列表', this.communityList)
    },
    provinceSubmit (data) {
      this.formItem.departure = data[0].name + data[1].name
      this.formItem.originate_province = data[0].name
      this.formItem.originate_city = data[1].name
      this.provinceShow = false
    },
    cardTypeBtn () {
      this.cardTypeShow = true
    },
    cardTypeChooseBtn (e) {
      this.cardTypeShow = true
    },
    provinceCancel () {
      this.provinceShow = false
    },
    chufaBtn () {
      this.provinceShow = true
    },
    dateCancel () {
      this.dateShow = false
    },
    dateSubmit () {
      this.formItem.arrive_time = this.datePicker.getFullYear() + '-' + (this.datePicker.getMonth() + 1) + '-' + this.datePicker.getDate()
      this.dateShow = false
    },
    arriveTimeBtn () {
      this.dateShow = true
    },
    submit () {
      // 校验姓名
      if (this.formItem.name === '' || this.formItem.name === undefined || this.formItem.name === null) {
        Toast.fail('请输入姓名')
        return false
      }
      // 校验性别
      if (this.formItem.sex === '') {
        Toast.fail('请选择性别')
        return false
      }
      // 校验证件类型
      if (this.formItem.card_type === '' || this.formItem.card_type === undefined || this.formItem.card_type === null || this.formItem.card_type === 0) {
        Toast.fail('请选择身份证类型')
        return false
      }
      // 校验证件号
      if (this.formItem.card_no === '' || this.formItem.card_no === undefined || this.formItem.card_no === null) {
        Toast.fail('请输入证件号码')
        return false
      } else {
        if (this.formItem.card_type === 1) {
          const rtn = identityCodeValid(this.formItem.card_no)
          console.log('身份证校验原因', rtn.tip)
          console.log('身份证校验状态', rtn.pass)
          if (!rtn.pass) {
            Toast.fail(rtn.tip)
            return false
          }
        }
      }
      // 校验手机号
      if (!identityMobile(this.formItem.tel)) {
        Toast.fail('输入正确手机号')
        return false
      }
      // 校验是否常住
      if (this.formItem.is_permanent === '') {
        Toast.fail('请选择是否常住居民')
        return false
      }
      // 校验区域类型
      if (this.formItem.area_type === '') {
        Toast.fail('请选择区域类型')
        return false
      }
      // 下面三个处理需放在校验前
      // 区域处理
      this.areaList.forEach(item => {
        if (this.formItem.area_id === item.id) {
          this.formItem.area = item.text
          console.log('选中的区域名', this.formItem.area)
        }
      })
      // 街道处理
      this.streetList.forEach(item => {
        if (this.formItem.street_id === item.id) {
          this.formItem.street = item.text
          console.log('选中的街道名', this.formItem.street)
        }
      })
      // 社区处理 - 社区状态
      if (this.formItem.area_type === 1) {
        this.communityList.forEach(item => {
          if (this.formItem.community_id === item.id) {
            this.formItem.community = item.text
            console.log('选中的社区名', this.formItem.community)
          }
        })
      }
      // 校验请选择现居区域
      if (this.formItem.area === '') {
        Toast.fail('请选择现居区域')
        return false
      }
      // 校验请选择现居街道
      if (this.formItem.street === '') {
        Toast.fail('请选择现居街道')
        return false
      }
      // 校验请选择现居社区
      if (this.formItem.community === '') {
        Toast.fail('请选择或填写现居社区(乡村)')
        return false
      }
      // 校验地址
      if (this.formItem.loc_address === '' || this.formItem.loc_address === undefined || this.formItem.loc_address === null) {
        Toast.fail('请选择居住地址')
        return false
      }
      // 校验出发地
      if (this.formItem.is_permanent === '0' && (this.formItem.departure === '' || this.formItem.departure === undefined || this.formItem.departure === null)) {
        Toast.fail('请选择来(返)沈出发地')
        return false
      }
      // 校验来（返）沈时间
      if (this.formItem.is_permanent === '0' && this.formItem.arrive_time === '') {
        Toast.fail('请选择来（返）沈时间')
        return false
      }
      // 校验来（返）事由
      if (this.cardnoState && this.formItem.back_reason === '') {
        Toast.fail('请选择来（返）沈事由')
        return false
      }
      // 非沈阳人处理
      if (!this.cardnoState) {
        this.formItem.back_reason = ''
      }
      // 来（返）沈时间处理
      if (this.formItem.is_permanent !== '0') {
        this.formItem.arrive_time = null
      }
      // 身份证去空格处理
      this.formItem.card_no.toString().trim()
      // 不知道儿童身份证号输入父母身份证号，后追加三位随机数
      if (this.formItem.card_type === 5) {
        let rand = ''
        for (let i = 0; i < 3; i++) {
          let r = Math.floor(Math.random() * 10)
          rand += r
        }
        this.formItem.card_no = this.formItem.card_no.toString().trim() + rand
        console.log('儿童身份证处理后', this.formItem.card_no)
      }
      // 途径地处理
      if (this.formItem.wuhan_radio === '1') {
        if (this.formItem.wenzhou_radio === '1') {
          if (this.formItem.hubei_radio === '1') {
            this.formItem.viaway = '武汉市,温州市,湖北其它城市'
          } else {
            this.formItem.viaway = '武汉市,温州市'
          }
        } else {
          if (this.formItem.hubei_radio === '1') {
            this.formItem.viaway = '武汉市,湖北其它城市'
          } else {
            this.formItem.viaway = '武汉市'
          }
        }
      } else {
        if (this.formItem.wenzhou_radio === '1') {
          if (this.formItem.hubei_radio === '1') {
            this.formItem.viaway = '温州市,湖北其它城市'
          } else {
            this.formItem.viaway = '温州市'
          }
        } else {
          if (this.formItem.hubei_radio === '1') {
            this.formItem.viaway = '湖北其它城市'
          } else {
            this.formItem.viaway = ''
          }
        }
      }
      // 来(返)沈情况 - 务工处理
      if (this.formItem.wugong_radio === '1') {
        this.formItem.concentration_type = '1'
        this.formItem.concentration_type_remark = this.formItem.wugong_name
      }
      // 来(返)沈情况 - 在校处理
      if (this.formItem.zaixiao_radio === '1') {
        this.formItem.concentration_type = '2'
        this.formItem.concentration_type_remark = this.formItem.zaixiao_name
      }
      // 来(返)沈情况 - 酒店处理
      if (this.formItem.jiudian_radio === '1') {
        this.formItem.concentration_type = '3'
        this.formItem.concentration_type_remark = this.formItem.jiudian_name
      }
      this.insertPermit()
    },
    // 表单提交
    insertPermit () {
      console.log('表单最终提交内容', this.formItem)
      // tab中提交
      const rtn = this.$refs.otherHandle.submit()
      console.log('测试节点')
      // 表单提交
      if (rtn.flag) {
        this.$delete(this.formItem, 'address')
        this.$delete(this.formItem, 'person')
        this.$delete(this.formItem, 'children')
        insertPermit(this.formItem).then(ret => {
          if (ret.data.errcode === 0) {
            console.log('保存回调', ret.data.data)
            if (ret.data.data.type === 0) {
              // 没注册过
              this.$dialog.alert({
                message: '您的电子通行证已生成!'
              }).then(() => {
                this.$router.push({
                  name: 'epidemic-submit-success',
                  query: {}
                })
                window.localStorage.removeItem('formData')
              })
            } else if (ret.data.data.type === 1) {
              // 注册过
              this.$dialog.alert({
                message: '您已注册过通行证!'
              }).then(() => {
                this.$router.push({
                  name: 'epidemic-submit-success',
                  query: {
                    cardno: this.formItem.card_no.toString().trim()
                  }
                })
                window.localStorage.removeItem('formData')
              })
            }
          } else {
            Toast.fail(ret.data.errmsg)
          }
        })
      } else {
        Toast.fail(rtn.tip)
      }
    },
    getUserPermitByOpenId () {
      this.loading = true
      getUserPermitByOpenId().then(ret => {
        if (ret.data.errcode === 0) {
          this.loading = false
          console.log('=提报页面获取个人信息判断=', ret.data)
          if (ret.data.data.result) {
            this.$router.push({
              name: 'epidemic-submit-success',
              query: {}
            })
          }
        } else {
          Toast.fail(ret.data.errmsg)
        }
      })
    },
    getMyInfo () {
      getUserLoginInfo().then(ret => {
        console.log('提报页获取登录信息回调', ret.data)
        if (ret.data.errcode === 200) {
          // 判断是否提报
          this.getUserPermitByOpenId()
        } else {
          Toast.fail('请刷新页面重新登录')
        }
      })
    },
    showMobileCodeAction () {
      this.mobileVerifyModel = true
      getCodePic().then(ret => {
        if (ret.data.errcode === 0) {
          this.mobileQrimg = ret.data.data.pic
          this.mobileVerifyKey = ret.data.data.key
        }
      })
    },
    // 去苹果机型白边
    bodyScrollTop () {
      document.body && (document.body.scrollTop = 0)
    },
    selectImg () {
      this.$common.wxCallBack(function () {
        wx.chooseImage({
          count: 1,
          sourceType: ['album', 'camera'],
          success: res => {
            let localIds001 = res.localIds
            wx.uploadImage({
              localId: localIds001[0], // 需要上传的图片的本地ID，由chooseImage接口获得
              isShowProgressTips: 1, // 默认为1，显示进度提示
              success: function (res1) {
                this.formItem.serverId = res1.serverId// 返回图片的服务器端ID
              }
            })
          }
        })
      })
    },
    onSendMobile () {
      createVerificationCode({
        key: this.mobileVerifyKey,
        vcode: this.mobileVerifyCode,
        mobile: this.formItem.tel
      }).then(ret => {
        if (ret.data.errcode === 0) {
          this.mobileVerifyModel = false
        }
      })
    },
    checkPostMobileCode () {
      checkVerificationCode({ mobile: this.formItem.tel, code: this.formItem.sms }).then(ret => {

      })
    }
  },
  mounted () {
    // 获取路由信息
    this.routeObj = this.$route.query
    console.log('表单页面路由信息', this.routeObj)
    // 获取登录信息
    // this.getUserPermitByOpenId()
    // 获取本地表单数据
    if (window.localStorage.getItem('formData')) {
      this.formItem = JSON.parse(window.localStorage.getItem('formData'))
      console.log('表单页面表单数据', this.formItem)
      window.localStorage.removeItem('formData')
    }
    // 身份证沈阳校验（防止选完地图后不触发）
    this.identityCardno()
    // 区域菜单数据预处理
    this.menuDataHandle()
    console.log('表单信息', this.formItem)
  },
  watch: {
    routeObj () {
    }
  }
}
</script>

<style scoped>
    .mobile-verify-code {
        display: flex;
        justify-content: center;
        padding: 15px;
    }

    .address-box {
        text-align: left;
    }

    .van-radio {
        float: left;
        margin-right: 10px;
    }

    .van-popup /deep/ .van-ellipsis {
        font-size: 0.95rem;
    }

    .title {
        width: 100%;
        padding: 0.625rem 0.9375rem;
        font-size: 12px;
    }

    .action-item .van-cell__title {
        -webkit-box-flex: inherit;
        -webkit-flex: inherit;
        flex: inherit;
        width: 5.625rem;
    }

    .content {
        width: 100%;
        background-color: #F5F5F5;
        box-sizing: border-box;
        -webkit-box-sizing: border-box;
    }

    .content >>> .van-cell {
        margin: 0 2%;
        width: 96%;
        font-size: 12px;
    }

    .content >>> .van-dialog__content {
        padding: 10px;
        text-align: center;
    }

    .van-field__control {
        font-size: 12px;
    }

    .content >>> .van-cell__value .van-field__body .van-field__control {
        font-size: 12px;
    }

    .city-card-common-btn:nth-of-type(1) {
        color: white;
        font-size: 12px;
        padding: 10px 0;
        width: 100%;
        border-radius: 5px;
        text-align: center;
        background-color: #7AB46D;
        margin-bottom: 5px;
    }

    .city-card-common-btn:nth-of-type(2) {
        color: white;
        font-size: 12px;
        padding: 10px 0;
        width: 100%;
        border-radius: 5px;
        text-align: center;
        background-color: #75ACDC;
    }

    .div-bot {
        padding: 8px;
    }

    .content >>> .van-cell__value {
        /*flex: inherit;*/
        font-size: 12px;
    }

    .content >>> .value-item .van-cell__value {
        width: 100%;
    }

    .van-action-sheet__cancel, .van-action-sheet__item {
        font-size: 12px;
    }

    .van-cell__value span {
        /*color: black;*/
    }

    .van-dropdown-menu {
        height: 25px;
    }

    .van-hairline--top-bottom::after {
        border-width: 0px 0px;
    }

    .chaochu >>> .van-cell__value {
        width: 100%;
    }

    .div1 >>> .van-cell__value {
        width: 100%;
    }

    .div2 >>> .van-cell__value {
        width: 100%;
    }

    .other-info .van-field__label.radio-item, .tou .van-field__label.radio-item {
        width: 8.625rem;
    }

    .suggest.van-cell.van-field span {
        width: 5rem;
    }
</style>
